{namespace be=TYPO3\CMS\Backend\ViewHelpers}

<f:be.pageRenderer
    includeRequireJsModules="{
        0:'TYPO3/CMS/Backend/ContextMenu',
        1:'TYPO3/CMS/Backend/Modal',
        2:'TYPO3/CMS/Backend/Tooltip'
    }"
/>

<h1>
    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:title" />
</h1>

<f:if condition="{isInWorkspace}">
    <f:then>
        <f:be.infobox
            title="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:notAvailableInWorkspace.title')}"
            message="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:notAvailableInWorkspace.message')}"
            state="-1"
        />
    </f:then>
    <f:else>
        <f:if condition="{subPages}">
            <f:then>
                <f:if condition="{hasInvisiblePage}">
                    <f:be.infobox
                        title="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:hasInvisiblePage.title')}"
                        message="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:hasInvisiblePage.message')}"
                        state="-1"
                    />
                </f:if>

                <h2>
                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:currentPageOrder" />
                </h2>

                <div class="table-fit">
                    <table class="table table-striped table-hover">
                        <thead>
                            <tr>
                                <th>
                                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:fieldTitle" />
                                </th>
                                <th>
                                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:fieldSubtitle" />
                                </th>
                                <th>
                                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:fieldNavTitle" />
                                </th>
                                <th>
                                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:fieldTstamp" />
                                </th>
                                <th>
                                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:fieldCrdate" />
                                </th>
                            </tr>
                        </thead>

                        <f:for each="{subPages}" as="page">
                            <tr>
                                <td class="text-nowrap">
                                    <core:iconForRecord table="pages" row="{page.record}" />
                                    <f:if condition="!{page.canEdit}">
                                        <span
                                            data-toggle="tooltip"
                                            data-title="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:noEditPermissions')}"
                                        >
                                            <core:icon identifier="status-status-permission-denied" />
                                        </span>
                                    </f:if>
                                    {page.record.title -> f:format.crop(maxCharacters: maxTitleLength)}
                                </td>
                                <td class="text-nowrap">
                                    {page.record.subtitle -> f:format.crop(maxCharacters: maxTitleLength)}
                                </td>
                                <td class="text-nowrap">
                                    {page.record.nav_title -> f:format.crop(maxCharacters: maxTitleLength)}
                                </td>
                                <td class="text-nowrap">
                                    <f:format.date format="{dateFormat} {timeFormat}">{page.record.tstamp}</f:format.date>
                                </td>
                                <td class="text-nowrap">
                                    <f:format.date format="{dateFormat} {timeFormat}">{page.record.crdate}</f:format.date>
                                </td>
                            </tr>
                        </f:for>
                    </table>
                </div>

                <h2>
                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrder"/>
                </h2>
                <a class="btn btn-default t3js-modal-trigger"
                    href="{be:moduleLink(route:'pages_sort', arguments:'{id:parentPageUid, newSortBy:\'title\'}')}"
                    data-severity="warning"
                    data-title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:pleaseConfirm')}"
                    data-button-close-text="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')}"
                    data-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderConfirm')}"
                >
                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderByTitle" />
                </a>
                <a class="btn btn-default t3js-modal-trigger"
                    href="{be:moduleLink(route:'pages_sort', arguments:'{id:parentPageUid, newSortBy:\'subtitle\'}')}"
                    data-severity="warning"
                    data-title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:pleaseConfirm')}"
                    data-button-close-text="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')}"
                    data-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderConfirm')}"
                >
                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderBySubtitle" />
                </a>
                <a class="btn btn-default t3js-modal-trigger"
                    href="{be:moduleLink(route:'pages_sort', arguments:'{id:parentPageUid, newSortBy:\'nav_title\'}')}"
                    data-severity="warning"
                    data-title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:pleaseConfirm')}"
                    data-button-close-text="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')}"
                    data-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderConfirm')}"
                >
                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderByNavtitle" />
                </a>
                <a class="btn btn-default t3js-modal-trigger"
                    href="{be:moduleLink(route:'pages_sort', arguments:'{id:parentPageUid, newSortBy:\'tstamp\'}')}"
                    data-severity="warning"
                    data-title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:pleaseConfirm')}"
                    data-button-close-text="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')}"
                    data-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderConfirm')}"
                >
                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderByTstamp" />
                </a>
                <a class="btn btn-default t3js-modal-trigger"
                    href="{be:moduleLink(route:'pages_sort', arguments:'{id:parentPageUid, newSortBy:\'create\'}')}"
                    data-severity="warning"
                    data-title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:pleaseConfirm')}"
                    data-button-close-text="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')}"
                    data-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderConfirm')}"
                >
                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderByCreate" />
                </a>
                <a class="btn btn-default t3js-modal-trigger"
                    href="{be:moduleLink(route:'pages_sort', arguments:'{id:parentPageUid, newSortBy:\'reverseCurrentSorting\'}')}"
                    data-severity="warning"
                    data-title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:pleaseConfirm')}"
                    data-button-close-text="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')}"
                    data-content="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderConfirm')}"
                >
                    <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:changeOrderReverse" />
                </a>
            </f:then>
            <f:else>
                <f:be.infobox
                    title="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:noSubpages.title')}"
                    message="{f:translate(key:'LLL:EXT:backend/Resources/Private/Language/locallang_pages_sort.xlf:noSubpages.message')}"
                    state="-1"
                />
            </f:else>
        </f:if>
    </f:else>
</f:if>
